<?php
/**
* Author	: TRUONG KIM PHUNG
* Class		: Education
* Description
	* Manage Education
	* Get
	* Add
	* Update
	* Delete
* Contact	:
	- Email : truongkimphung1982@gmail.com
	- Y!	: truongkimphung1982
	- Skype	: truongkimphung1982
**/
class Education extends Ecore_Db {
	var $cache;
	var $clear;
	public function __construct() {
		$this->cache = new Ecore_Cache();
		$this->clear = $this->cache->clear;
	}	
	/**
	 * GET INFORMATION EDUCATION BY ID
	 * @PARAM
			- $intEducateId
	 * @RESULT
			- Array | NULL
	 */
	public function get($intEducateId) {
		try {
			
			$this->prepare('call educations_get(?)');
			$this->bindParam(1 , $intEducateId	, PDO::PARAM_INT, 11);			
			$arrResult 	= $this->fetchAll();	
				
			return isset($arrResult[0]) ? $arrResult[0] : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::get - ' . $e->getMessage());
			
		}
	}
	
	/**
	 * GET TOP EDUCATION 
	 * @PARAM
			- $intEducateId
	 * @RESULT
			- Array | NULL
	 */
	public function getTopE($intCategoryId, $intSubId) {
		try {
			$this->prepare('call educations_get_top_ddht(?,?)');
			$this->bindParam(1 , $intCategoryId	, PDO::PARAM_INT, 11);			
			$this->bindParam(2 , $intSubId	, PDO::PARAM_INT, 11);			
			$arrResult 	= $this->fetchAll();						
			return isset($arrResult[0]) ? $arrResult[0] : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getTopE - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET INFORMATION EDUCATION BY CATEGORYID
	 * @PARAM
			- $intCategoryId
			- $intLanguage
	 * @RESULT
			- Array | NULL
	 */
	public function getCategory($intCategoryId, $intLanguage) {
		try {
			$this->prepare('call educations_getall_category(?,?)');
			$this->bindParam(1 , $intCategoryId	, PDO::PARAM_INT, 11);			
			$this->bindParam(2 , $intLanguage	, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();	
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getCategory - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET INFORMATION EDUCATION BY ID
	 * @PARAM
			- $intType
			- $intSpec
			- $intLanguage
			- $intCategoryId
			- $intOffset
			- $intLimit
			- $intTotal			: Assign value
	 * @RESULT
			- Array | NULL
	 */
	public function getAll($intType, $intSpec, $intCategoryId, $intOffset, $intLimit, $intEducateId=0, $intProvinceId=0, &$intTotal=0) {
		try {			
			
			$this->prepare('call educations_getall(?,?,?,?,?,?,?)');
			$this->bindParam(1, $intType		, PDO::PARAM_INT, 4);			
			$this->bindParam(2, $intSpec		, PDO::PARAM_INT, 11);		
			$this->bindParam(3, $intCategoryId	, PDO::PARAM_INT, 11);			
			$this->bindParam(4, $intOffset		, PDO::PARAM_INT, 11);			
			$this->bindParam(5, $intLimit		, PDO::PARAM_INT, 4);			
			$this->bindParam(6, $intEducateId	, PDO::PARAM_INT, 11);			
			$this->bindParam(7, $intProvinceId	, PDO::PARAM_INT, 11);			
			$arrResult 	= $this->fetchAll();	
			$intTotal	= isset($arrResult[0]['foundRows']) ? $arrResult[0]['foundRows'] : 0;			
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getAll - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET INFORMATION EDUCATION LIST
	 * @PARAM
			- $intLanguage
			- $intLimit
	 * @RESULT
			- Array | NULL
	 */
	public function getAllForMap($intLanguage, $intLimit=MAP_LIMIT) {
		try {
			$this->prepare('call educations_getall_map(?,?)');			
			$this->bindParam(1, $intLanguage	, PDO::PARAM_INT, 4);			
			$this->bindParam(2, $intLimit		, PDO::PARAM_INT, 6);			
			$arrResult 	= $this->fetchAll();	
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getAllForMap - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET TOP EDUCATION
	 * @PARAM
			- $intLanguage
			- $intLimit
	 * @RESULT
			- Array | NULL
	 */
	public function getTop($intLanguage, $intLimit=TOP_LIMIT) {
		try {
			$this->prepare('call educations_top(?,?)');		
			$this->bindParam(1, $intLanguage	, PDO::PARAM_INT, 4);			
			$this->bindParam(2, $intLimit		, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getTop - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET TOP CATEGORY
	 * @PARAM
			- $intCategoryId
			- $intLanguage
			- $intLimit
	 * @RESULT
			- Array | NULL
	 */
	public function getTopCate($intCategoryId, $intLanguage, $intLimit=TOP_EDUCATEION) {
		try {
			$this->prepare('call educations_get_top_cate(?,?,?)');		
			$this->bindParam(1, $intCategoryId	, PDO::PARAM_INT, 11);			
			$this->bindParam(2, $intLanguage	, PDO::PARAM_INT, 4);			
			$this->bindParam(3, $intLimit		, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getTopCate - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET EDUCATION SUB
	 * @PARAM
			- $intSub
	 * @RESULT
			- Array | NULL
	 */
	public function getEducationS($intSub) {
		try {
			$this->prepare('call educations_s_getall_com(?)');		
			$this->bindParam(1, $intSub	, PDO::PARAM_INT, 11);					
			$arrData 	= $this->fetchAll();
			$arrResult	= null;
			if(isset($arrData) && is_array($arrData)) {
				foreach($arrData as $value) {
					$arrResult[$value['educateid']] = $value['educateid'];
				}
			}
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getEducationS - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET EDUCATION SUB
	 * @PARAM
			- $intSub
	 * @RESULT
			- Array | NULL
	 */
	public function getEducationSpec($intEducateId, $isCombobox=1) {
		try {
			$this->prepare('call educations_s_getall(?)');		
			$this->bindParam(1, $intEducateId, PDO::PARAM_INT, 11);					
			$arrData 	= $this->fetchAll();			
			if($isCombobox) {
				$arrResult	= null;
				if(isset($arrData) && is_array($arrData)) {
					foreach($arrData as $value) {
						$arrResult[$value['educateid']] = $value['educateid'];
					}
				}
				return isset($arrResult) ? $arrResult : null;
			} else {
				return isset($arrData) ? $arrData : null;
			}
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getEducationSpec - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET IMAGE BY ALBUMID
	 * @PARAM
			- $intAlbumId
			- $intOffset
			- $intLimit
	 * @RESULT
			- Array | NULL
	 */
	public function getImage($intAlbumId, $intOffset=0, $intLimit=ABOUT_IMAGE_LIMIT) {
		try {						
			$this->prepare('call educations_img_getall(?,?,?)');		
			$this->bindParam(1, $intAlbumId, PDO::PARAM_INT, 11);
			$this->bindParam(2, $intOffset, PDO::PARAM_INT, 11);
			$this->bindParam(3, $intLimit, PDO::PARAM_INT, 11);
			$arrResult 	= $this->fetchAll();
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getImage - ' .$e->getMessage());			
			
		}
	}
/***************************************************/
/** EDUCATION CMT */
/***************************************************/
	/**
	 * GET INFO COMMENT BY COMMENT ID
	 * @PARAM
			- $intEcmtId
	 * @RESULT
			- Array | NULL
	 */
	function getCmt($intEcmtId) {
		try {
			$this->prepare('call educations_cmt_get(?)');
			$this->bindParam(1, $intEcmtId	, PDO::PARAM_INT, 11);
			$arrResult 	= $this->fetchAll();
			return isset($arrResult[0]) ? $arrResult[0] : null;	
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getCmt - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET COMMENT BY USERID
	 * @PARAM
			- $intUserId
			- $intEducateId
	 * @RESULT
			- Array | NULL
	 */
	function getCmtUser($intUserId, $intEducateId) {
		try {
			$this->prepare('call educations_cmt_user(?,?)');
			$this->bindParam(1, $intUserId		, PDO::PARAM_INT, 11);
			$this->bindParam(2, $intEducateId	, PDO::PARAM_INT, 11);
			$arrResult 	= $this->fetchAll();
			return isset($arrResult) ? $arrResult : null;	
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getCmtUser - ' . $e->getMessage());
			
		}
	}
    /**
	 * GET TOTAL COMMENT BY EDUCATEID
	 * @PARAM
			- $intEducateId
			- $intType
			- $intOffset
			- $intLimit
			- $intTotal
	 * @RESULT
			- Integer
	 */
	function getTotalForCmt($intType, $intEducateId, $intOffset=0, $intLimit=CLIENT_LIMIT, $intTotal=-1) {		
		return $this->getAllForCmt($intEducateId, $intOffset, $intLimit, $intTotal, $intType);
	}
	/**
	 * GET LIST COMMENT BY EDUCATEID
	 * @PARAM
			- $intEducateId
			- $intOffset
			- $intLimit
			- $intTotal			: Assign value
	 * @RESULT
			- Array | NULL | Integer
	 */
	public function getAllForCmt($intType, $intEducateId, $intOffset=0, $intLimit=CLIENT_LIMIT, &$intTotal=-1) {
		try {
			$intReturn	= $intTotal;			
			$this->prepare('call educations_cmt_getall(?,?,?,?)');
			$this->bindParam(1, $intType		, PDO::PARAM_INT, 4);			
			$this->bindParam(2, $intEducateId	, PDO::PARAM_INT, 11);			
			$this->bindParam(3, $intOffset		, PDO::PARAM_INT, 11);			
			$this->bindParam(4, $intLimit		, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();				
			if($intReturn < 0) {
				$intTotal	= isset($arrResult[0]['foundRows']) ? $arrResult[0]['foundRows'] : 0;
				return $intTotal;
			}
			else
				return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getAllForCmt - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET TOP COMMENT & RATING
	 * @PARAM
			- $intEducateId
			- $intOffset
			- $intLimit
	 * @RESULT
			- Array | NULL | Integer
	 */
	public function getTopForCmt($intEducateId=0,$intOffset=0, $intLimit=RATING_LIMIT) {
		try {
			$this->prepare('call educations_cmt_getall_rating(?,?,?)');
			$this->bindParam(1, $intEducateId	, PDO::PARAM_INT, 11);			
			$this->bindParam(2, $intOffset		, PDO::PARAM_INT, 11);			
			$this->bindParam(3, $intLimit		, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();				
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getTopForCmt - ' . $e->getMessage());
			
		}
	}
    //
    /**
	 * GET USER COMMENT BY EDUCATION
	 * @PARAM
			- $intEducateId
			- $intLimit
	 * @RESULT
			- Array | NULL
	 */
	public function getAllForCmtUser($intEducateId, $intLimit=USER_LIMIT) {
		try {
			$this->prepare('call educations_cmt_getall_user(?,?)');
			$this->bindParam(1, $intEducateId	, PDO::PARAM_INT, 11);			
			$this->bindParam(2, $intLimit		, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();				
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getAllForCmtUser - ' . $e->getMessage());
			
		}
	}
	/**
	 * COMMENT EDUCATION
	 * @PARAM
			- $intUserId
			- $intEducateId
			- $strTitle
			- $strContent
			- $strErateId	 
	 */
	public function addEducationCmt($intUserId, $intEducateId, $strTitle, $strContent, $strErateId='') {
		try {
			$this->prepare('call educations_cmt_add(?,?,?,?,?)');
			$this->bindParam(1, $intUserId		, PDO::PARAM_INT, 4);			
			$this->bindParam(2, $intEducateId	, PDO::PARAM_INT, 4);			
			$this->bindParam(3, $strTitle		, PDO::PARAM_STR, 255);			
			$this->bindParam(4, $strContent		, PDO::PARAM_STR);			
			$this->bindParam(5, $strErateId		, PDO::PARAM_STR, 100);	
			$arrResult 	= $this->fetchAll();
			$intEcmtId	= isset($arrResult[0]['ecmtid']) ? $arrResult[0]['ecmtid'] : -1;
			if($intEcmtId > 0) {
				$this->clear->deleteEducation($intEducateId);
				$this->addEducationU($intUserId, $intEducateId, 2);
				$arrUser	= $this->getEducationU($intEducateId);				
				if(isset($arrUser)) {
					$objNotification = new Notification();
					$objBehaviour	 = new Behaviour();
					$strCnt			 = Ecore_Function::wordCut($strContent);		 
					$strParams		 = Zend_Json::encode(array('id'=>$intEducateId,'ecmtid'=>$intEcmtId,'cnt'=>$strCnt));
					$intStype		 = $strErateId == '' ? 4 : 5;
					foreach($arrUser as $val) {						
						if($intUserId != $val['userid']) {
							$objNotification->add(1, $val['userid'], $intUserId, $intEcmtId, $strParams);
							$objBehaviour->addUpdate($val['userid'], $intUserId, $intEducateId, $intEcmtId, 1, $intStype);
						}
					}
				}
			}
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::addEducationCmt - ' . $e->getMessage());
			
		}
	}
/***************************************************/
/** EDUCATION RATE */
/***************************************************/
	/**
	 * RATED
	 * @PARAM
			- $intUserId
			- $intEducateId
			- $intType			: {0:month-year;1:like;2:service;3:price;4:certificate}
			- $intPoint
			- $intMonth
			- $intYear
			- $intErateId		: Assign Id
	 * @RESULT
			- Integer
	 */
	public function addEducationR($intUserId, $intEducateId, $intType, $intPoint, $intMonth, $intYear, &$intErateId=0) {
		try {
			$this->prepare('call educations_r_add(?,?,?,?,?,?)');
			$this->bindParam(1, $intUserId		, PDO::PARAM_INT, 11);			
			$this->bindParam(2, $intEducateId	, PDO::PARAM_INT, 11);			
			$this->bindParam(3, $intType		, PDO::PARAM_INT, 4);			
			$this->bindParam(4, $intPoint		, PDO::PARAM_INT, 4);			
			$this->bindParam(5, $intMonth		, PDO::PARAM_INT, 4);			
			$this->bindParam(6, $intYear		, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();	
			$intError	= isset($arrResult[0]['errCode']) ? $arrResult[0]['errCode'] : -1;
			if($intError == 0) {
				$intErateId = isset($arrResult[0]['erateid']) ? $arrResult[0]['erateid'] : 0;
			}
			return $intError;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::addEducationR - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET RATE INFO
	 * @PARAM
			- $intUserId
			- $intEducateId
	 * @RESULT
			- Array | NULL
	 */
	public function getEducationR($intUserId, $intEducateId) {
		try {
			$this->prepare('call educations_r_get(?,?)');
			$this->bindParam(1, $intUserId		, PDO::PARAM_INT, 11);			
			$this->bindParam(2, $intEducateId	, PDO::PARAM_INT, 11);			
			$arrResult 	= $this->fetchAll();	
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getEducationR - ' . $e->getMessage());
			
		}
	}
/***************************************************/
/** EDUCATION LIKE */
/***************************************************/
    /**
	 * LOG LIKE EDUCATION
	 * @PARAM				
		- $intUserId
		- $intEducateId		
	 * @RESULT errCode {
					0	: Success
					1	: Rated
					2	: Not rate my educate
				}
	 **/ 
    public function addEducationL($intUserId, $intEducateId) {
		try {
			$this->prepare('call educations_l_add(?,?)');
			$this->bindParam(1, $intUserId		, PDO::PARAM_INT, 11);
			$this->bindParam(2, $intEducateId	, PDO::PARAM_INT, 11);
			$arrResult 	= $this->fetchAll();	
			$intError	= isset($arrResult[0]['errCode']) ? $arrResult[0]['errCode'] : -1;
			if($intError == 0) {
				$this->addEducationU($intUserId, $intEducateId, 3);
				$arrUser	= $this->getEducationU($intEducateId);
				if(isset($arrUser)) {
					$objNotification = new Notification();
					$objBehaviour	 = new Behaviour();
					$strCnt			 = Ecore_Function::wordCut($strContent);		 
					$strParams		 = Zend_Json::encode(array('id'=>$intEducateId));
					foreach($arrUser as $val) {						
						if($intUserId != $val['userid']) {
							$objNotification->add(2, $val['userid'], $intUserId, $intEducateId, $strParams);
							$objBehaviour->addUpdate($val['userid'], $intUserId, $intEducateId, 0, 1, 6);
						}
					}
				}
			}
			return $intError;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::addEducationL - ' . $e->getMessage());
			
		}
	}
    /**
	 * LOG LIKE EDUCATION COMMENT
	 * @PARAM				
		- $intUserId
		- $intEducateId		
		- $intEcmtId		
	 * @RESULT errCode {
					0	: Success
					1	: Rated
					2	: Not rate my educate
				}
	 **/
	public function addEducationCL($intUserId, $intEducateId, $intEcmtId) {
		try {
			$this->prepare('call educations_cl_add(?,?,?,?)');
			$this->bindParam(1, $intUserId		, PDO::PARAM_INT, 11);
			$this->bindParam(2, $intEducateId	, PDO::PARAM_INT, 11);
			$this->bindParam(3, $intEcmtId		, PDO::PARAM_INT, 11);
			$this->bindParam(4, $intType=1		, PDO::PARAM_INT, 4);
			$arrResult 	= $this->fetchAll();	
			$intError	= isset($arrResult[0]['errCode']) ? $arrResult[0]['errCode'] : -1;
			if($intError == 0) {
				$this->addEducationU($intUserId, $intEducateId, 3);
				$arrUser	= $this->getEducationU($intEducateId);
				if(isset($arrUser)) {
					$objNotification = new Notification();
					$objBehaviour	 = new Behaviour();
					$strCnt			 = Ecore_Function::wordCut($strContent);		 
					$strParams		 = Zend_Json::encode(array('id'=>$intEducateId,'ecmtid'=>$intEcmtId));
					foreach($arrUser as $val) {						
						if($intUserId != $val['userid']) {
							$objNotification->add(3, $val['userid'], $intUserId, $intEcmtId, $strParams);
							$objBehaviour->addUpdate($val['userid'], $intUserId, $intEducateId, $intEcmtId, 1, 7);
						}
					}
				}
			}
			return $intError;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::addEducationCL - ' . $e->getMessage());
			
		}
	}
/***************************************************/
/** EDUCATION COURSE */
/***************************************************/
	/**
	 * GET EDUCATE COURSE INFO
	 * @PARAM
			- $intEducateId
			- $intLimit
	 * @RESULT
			- Array | NULL
	 */
	public function getEcourseTop($intEducateId, $intLimit=50) {
		try {
			$this->prepare('call educations_cou_top(?,?)');
			$this->bindParam(1, $intEducateId	, PDO::PARAM_INT, 11);			
			$this->bindParam(2, $intLimit		, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();	
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getEcourseTop - ' . $e->getMessage());
			
		}
	}
/***************************************************/
/** EDUCATION STU */
/***************************************************/
	/**
	 * ADD EDU STUDY
	 * @PARAM
			- $intUserId
			- $intEducateId
			- $intType
			- $intId: Assign 
	 * @RESULT errCode {
					0	: Success
					1	: Exists
				}
	 */
	public function addEstudy($intUserId,$intEducateId,$intType=1,&$intId=0) {
		try {
			$this->prepare('call educations_stu_add(?,?,?)');
			$this->bindParam(1, $intUserId		, PDO::PARAM_INT, 11);			
			$this->bindParam(2, $intEducateId	, PDO::PARAM_INT, 11);			
			$this->bindParam(3, $intType		, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();	
			$intId 		= isset($arrResult[0]['id']) ? $arrResult[0]['id'] : 0;
			$intError	= isset($arrResult[0]['errCode']) ? $arrResult[0]['errCode'] : -1;
			if($intError == 0) {
				$this->addEducationU($intUserId, $intEducateId, 1);
			}
			return $intError;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::addEstudy - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET USER EDU STUDY
	 * @PARAM
			- $intEducateId
			- $intType
			- $intLimit
	 * @RESULT
			- Array | NULL
	 */
	public function getUestudy($intEducateId, $intType, $intLimit=USER_LIMIT) {
		try {
			$this->prepare('call educations_stu_getall_user(?,?,?)');
			$this->bindParam(1, $intEducateId	, PDO::PARAM_INT, 11);			
			$this->bindParam(2, $intType		, PDO::PARAM_INT, 11);			
			$this->bindParam(3, $intLimit		, PDO::PARAM_INT, 4);			
			$arrResult 	= $this->fetchAll();	
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getUestudy - ' . $e->getMessage());
			
		}
	}
/***************************************************/
/** EDUCATION USER */
/***************************************************/
	/**
	 * ADD EDUCATION USER
	 * @PARAM
			- $intUserId
			- $intEducateId
			- $intType {0: follow; 1:study, 2:cmt; 3:like}
	 */
	public function addEducationU($intUserId, $intEducateId, $intType) {
		try {
			$intType	= Ecore_Function::bit($intType);
			$this->prepare('call educations_u_add(?,?,?)');
			$this->bindParam(1, $intUserId		, PDO::PARAM_INT, 11);			
			$this->bindParam(2, $intEducateId	, PDO::PARAM_INT, 11);			
			$this->bindParam(3, $intType		, PDO::PARAM_INT, 6);
			$arrResult 	= $this->fetchAll();
			$intError	= isset($arrResult[0]['errCode']) ? $arrResult[0]['errCode'] : -1;
			if($intError == 0) {
				$this->clear->deleteEducationU($intEducateId, $intType);
			}
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::addEducationU - ' . $e->getMessage());
			
		}
	}
	/**
	 * GET EDUCATION USER
	 * @PARAM			
			- $intEducateId
			- $intType
	 */
	public function getEducationU($intEducateId, $intType=-1) {
		try {
			if($intType >= 0) $intType = Ecore_Function::bit($intType);			
			$strKey		= EDUCATION_GETEDUCATIONU . $intEducateId . $intType;
			$arrResult	= $this->cache->get($strKey);
			if(!Ecore_Function::isCached($arrResult)) {
				$this->prepare('call educations_u_getall(?,?)');			
				$this->bindParam(1, $intEducateId	, PDO::PARAM_INT, 11);			
				$this->bindParam(2, $intType		, PDO::PARAM_INT, 6);			
				$arrResult	= $this->fetchAll();
				$this->cache->set($strKey, $arrResult, EDUCATION_GETEDUCATIONU_EXPIRE);
			}
			return isset($arrResult) ? $arrResult : null;
		} catch(Exception $e) {
			Ecore_Function::logDb('Education::getEducationU - ' . $e->getMessage());
			
		}
	}
}
?>